package com.xauto.pioneer.appuser.adapter;

import android.app.Activity;
import android.view.View;
import android.widget.TextView;

import com.xauto.pioneer.appuser.R;
import com.xauto.pioneer.appuser.model.CarAdditionalInfo;

import static com.xauto.pioneer.appuser.R.id.tvRefuelDate;
import static com.xauto.pioneer.appuser.R.id.tvRefuelMoney;
import static com.xauto.pioneer.appuser.R.id.tvRefuelName;

/**
 * Created by Lemon on 2015/12/11.
 * Desc:附加费用列表 适配器
 */
public class AdditionalAdapter extends AbsAdapter<CarAdditionalInfo> {

    public AdditionalAdapter(Activity context, int layout) {
        super(context, layout);
    }

    @Override
    public ViewHolder<CarAdditionalInfo> getHolder() {
        return new TemplateViewHolder();
    }


    private class TemplateViewHolder implements ViewHolder<CarAdditionalInfo> {

        private TextView tvOrderNo;
        private TextView tvOrderStatus;
        private TextView tvAdditionalName;
        private TextView tvAdditionalDate;
        private TextView tvAdditionalMoney;

        @Override
        public void initViews(View v, int position) {
            tvOrderNo = (TextView) v.findViewById(R.id.tvOrderNo);
            tvOrderStatus = (TextView) v.findViewById(R.id.tvOrderStatus);
            tvAdditionalName = (TextView) v.findViewById(tvRefuelName);
            tvAdditionalDate = (TextView) v.findViewById(tvRefuelDate);
            tvAdditionalMoney = (TextView) v.findViewById(tvRefuelMoney);
        }

        @Override
        public void updateData(CarAdditionalInfo CarAdditionalInfo, int position) {
            tvOrderNo.setText(context.getString(R.string.order_no,CarAdditionalInfo.car_order_no));
            tvOrderStatus.setText(CarAdditionalInfo.additional_order_status_name);
            switch (CarAdditionalInfo.additional_order_status_style_color){
                case "0":
                    tvOrderStatus.setTextColor(context.getResources().getColor(R.color.black));
                    break;
                case "1":
                    tvOrderStatus.setTextColor(context.getResources().getColor(R.color.red));
                    break;
                case "2":
                    tvOrderStatus.setTextColor(context.getResources().getColor(R.color.grey));
                    break;
            }
            tvAdditionalName.setText("项目类:"+CarAdditionalInfo.additional_order_category_name);
            tvAdditionalDate.setText("日期:"+CarAdditionalInfo.date_added);
            tvAdditionalMoney.setText("费用: "+CarAdditionalInfo.additional_amount_format);
        }

        @Override
        public void doOthers(CarAdditionalInfo CarAdditionalInfo, int position) {

        }
    }
}
